package com.lemon.smartsafetynew.net.services;

import android.content.Context;

import com.lemon.android.http.LemonRequestParams;
import com.lemon.smartsafety.app.Constants;
import com.lemon.smartsafety.app.IApplication;
import com.lemon.smartsafety.app.RefreshType;
import com.lemon.smartsafety.http.UrlInfo;
import com.lemon.smartsafety.http.callback.HandlerCallback;
import com.lemon.smartsafety.http.service.BaseHttpServices;
import com.lemon.smartsafetynew.entity.contact.PersonVo;
import com.lemon.smartsafetynew.entity.ledger.LedgerBuildingCheckItemDetailVo;
import com.lemon.smartsafetynew.entity.ledger.LedgerBuildingCheckItemVo;
import com.lemon.smartsafetynew.entity.ledger.LedgerBuildingItemVo;
import com.lemon.smartsafetynew.entity.ledger.LedgerBuildingStatisticsVo;
import com.lemon.smartsafetynew.entity.ledger.LedgerPatrolPersonnelStatisticsVo;
import com.lemon.smartsafetynew.entity.ledger.LedgerRadarVo;
import com.lemon.smartsafetynew.entity.ledger.LedgerStatisticsVo;
import com.lemon.smartsafetynew.entity.patrol.SafePatrolTaskVo;
import com.lemon.smartsafetynew.entity.work.OverViewVo;
import com.lemon.smartsafetynew.util.constants.KeyConstants;
import com.zhy.http.okhttp.OkHttpUtils;

import java.util.List;

/**
 * Created by Andrew on 2017/8/14.
 */

public class SafeLedgerServices extends BaseHttpServices {


    public static final String TAG = "SafeLedgerServices";

    public SafeLedgerServices(Context context) {
        super(context);
    }

    /**
     * 初始化，等同使用构造函数
     *
     * @return
     */
    public static SafeLedgerServices init() {
        return new SafeLedgerServices(IApplication.context());
    }


    /**
     * 初始化，等同使用构造函数
     *
     * @param context
     * @return
     */
    public static SafeLedgerServices init(Context context) {
        return new SafeLedgerServices(context);
    }


    /**
     * 安全台账之安全巡查详情
     *
     * @param params
     */
    public void getSafePatrolDetailData(LemonRequestParams params) {
        HandlerCallback<LedgerStatisticsVo> callback = new HandlerCallback<LedgerStatisticsVo>(KeyConstants.URL_GET_SAFE_LEDGER_STATISTICS_OF_SAFE_PATROL) {
        };
        String serverUrl = mSharedPreferencesServer.getRequestUrl(UrlInfo.GET_SAFE_LEDGER_STATISTICS_OF_SAFE_PATROL, Constants.SERVER_V2);
        OkHttpUtils.post()
                .url(serverUrl)
                .tag(callback.getTag())
                .params(params)
                .build().execute(callback);
    }


    /**
     * 安全台账之安全巡查更多详情
     *
     * @param params
     */
    public void getSafePatrolMoreDetailData(LemonRequestParams params) {
        HandlerCallback<LedgerStatisticsVo> callback = new HandlerCallback<LedgerStatisticsVo>(KeyConstants.URL_GET_SAFE_LEDGER_STATISTICS_OF_SAFE_PATROL_MORE) {
        };
        String serverUrl = mSharedPreferencesServer.getRequestUrl(UrlInfo.GET_SAFE_LEDGER_STATISTICS_OF_SAFE_PATROL, Constants.SERVER_V2);
        OkHttpUtils.post()
                .url(serverUrl)
                .tag(callback.getTag())
                .params(params)
                .build().execute(callback);
    }

    /**
     * 安全台账之安全巡查 巡查记录
     *
     * @param params
     */
    public void getSafePatrolRecordData(RefreshType type, LemonRequestParams params, String f_status) {
        HandlerCallback<List<SafePatrolTaskVo>> callback = new HandlerCallback<List<SafePatrolTaskVo>>(KeyConstants.URL_GET_SAFE_LEDGER_PATROL_RECORD + f_status) {
        };
        callback.setOther(type);
        String serverUrl = mSharedPreferencesServer.getRequestUrl(UrlInfo.GET_SAFE_LEDGER_PATROL_RECORD, Constants.SERVER_V2);
        OkHttpUtils.post()
                .url(serverUrl)
                .tag(callback.getTag())
                .params(params)
                .build().execute(callback);
    }

    /**
     * 安全台账之安全巡查 人员统计
     *
     * @param params
     */
    public void getSafePatrolPersonnelStatisticsVo(RefreshType type, LemonRequestParams params) {
        HandlerCallback<List<LedgerPatrolPersonnelStatisticsVo>> callback = new HandlerCallback<List<LedgerPatrolPersonnelStatisticsVo>>(KeyConstants.URL_GET_SAFE_LEDGER_PATROL_PERSONNEL_STATISTICS) {
        };
        callback.setOther(type);
        String serverUrl = mSharedPreferencesServer.getRequestUrl(UrlInfo.GET_SAFE_LEDGER_PATROL_PERSONNEL_STATISTICS, Constants.SERVER_V2);
        OkHttpUtils.post()
                .url(serverUrl)
                .tag(callback.getTag())
                .params(params)
                .build().execute(callback);
    }

    /**
     * 安全台账之安全巡查--人员统计--个人巡查列表
     *
     * @param params
     */
    public void getSafePatrolPersonnelTaskList(RefreshType type, LemonRequestParams params, String f_status) {
        HandlerCallback<List<SafePatrolTaskVo>> callback = new HandlerCallback<List<SafePatrolTaskVo>>(KeyConstants.URL_GET_SAFE_LEDGER_PATROL_PERSONNEL_TASK_LIST + f_status) {
        };
        callback.setOther(type);
        String serverUrl = mSharedPreferencesServer.getRequestUrl(UrlInfo.GET_SAFE_LEDGER_PATROL_PERSONNEL_TASK_LIST, Constants.SERVER_V2);
        OkHttpUtils.post()
                .url(serverUrl)
                .tag(callback.getTag())
                .params(params)
                .build().execute(callback);
    }

    /**
     * 安全台账之企业整体状态
     *
     * @param params
     */
    public void getCompanyStatus(LemonRequestParams params) {
        HandlerCallback<LedgerRadarVo> callback = new HandlerCallback<LedgerRadarVo>(KeyConstants.URL_GET_SAFE_LEDGER_COMPANY_STATUS) {
        };
        String serverUrl = mSharedPreferencesServer.getRequestUrl(UrlInfo.GET_SAFE_LEDGER_COMPANY_STATUS, Constants.SERVER_V2);
        OkHttpUtils.post()
                .url(serverUrl)
                .tag(callback.getTag())
                .params(params)
                .build().execute(callback);
    }

    /**
     * 安全台账之应急处置获取紧急联系人
     *
     * @param params
     */
    public void getEmergencyUser(LemonRequestParams params) {
        HandlerCallback<List<PersonVo>> callback = new HandlerCallback<List<PersonVo>>(KeyConstants.URL_GET_SAFE_LEDGER_EMERGENCY_USER) {
        };
        String serverUrl = mSharedPreferencesServer.getRequestUrl(UrlInfo.GET_SAFE_LEDGER_EMERGENCY_USER);
        OkHttpUtils.post()
                .url(serverUrl)
                .tag(callback.getTag())
                .params(params)
                .build().execute(callback);
    }

    /**
     * 安全台账之建筑安全
     *
     * @param params
     */
    public void getBuildingStatistics(LemonRequestParams params) {
        HandlerCallback<LedgerBuildingStatisticsVo> callback = new HandlerCallback<LedgerBuildingStatisticsVo>(KeyConstants.URL_GET_SAFE_LEDGER_STATISTICS_OF_BUILDING) {
        };
        String serverUrl = mSharedPreferencesServer.getRequestUrl(UrlInfo.GET_SAFE_LEDGER_STATISTICS_OF_BUILDING, Constants.SERVER_V2);
        OkHttpUtils.post()
                .url(serverUrl)
                .tag(callback.getTag())
                .params(params)
                .build().execute(callback);
    }

    /**
     * 安全台账之建筑安全详情，数据统计
     *
     * @param params
     */
    public void getBuildingStatisticsDetail(LemonRequestParams params) {
        HandlerCallback<LedgerBuildingStatisticsVo> callback = new HandlerCallback<LedgerBuildingStatisticsVo>(KeyConstants.URL_GET_SAFE_LEDGER_STATISTICS_OF_BUILDING_DETAIL) {
        };
        String serverUrl = mSharedPreferencesServer.getRequestUrl(UrlInfo.GET_SAFE_LEDGER_STATISTICS_OF_BUILDING_DETAIL, Constants.SERVER_V2);
        OkHttpUtils.post()
                .url(serverUrl)
                .tag(callback.getTag())
                .params(params)
                .build().execute(callback);
    }


    /**
     * 安全台账之建筑安全---建筑列表
     *
     * @param params
     */
    public void getBuildingList(LemonRequestParams params) {
        HandlerCallback<List<LedgerBuildingItemVo>> callback = new HandlerCallback<List<LedgerBuildingItemVo>>(KeyConstants.URL_GET_SAFE_LEDGER_BUILDING_LIST) {
        };
        String serverUrl = mSharedPreferencesServer.getRequestUrl(UrlInfo.GET_SAFE_LEDGER_BUILDING_LIST, Constants.SERVER_V2);
        OkHttpUtils.post()
                .url(serverUrl)
                .tag(callback.getTag())
                .params(params)
                .build().execute(callback);
    }

    /**
     * 安全台账之建筑安全---建筑检查项列表
     * @param type
     * @param params
     */
    public void getBuildingCheckItemList(RefreshType type, LemonRequestParams params) {
        HandlerCallback<List<LedgerBuildingCheckItemVo>> callback = new HandlerCallback<List<LedgerBuildingCheckItemVo>>(KeyConstants.URL_GET_SAFE_LEDGER_BUILDING_CHECK_ITEM_LIST) {
        };
        callback.setOther(type);
        String serverUrl = mSharedPreferencesServer.getRequestUrl(UrlInfo.GET_SAFE_LEDGER_BUILDING_CHECK_ITEM_LIST, Constants.SERVER_V2);
        OkHttpUtils.post()
                .url(serverUrl)
                .tag(callback.getTag())
                .params(params)
                .build().execute(callback);
    }

    /**
     * 安全台账之建筑安全---建筑检查项详情
     * @param params
     */
    public void getBuildingCheckItemDetail(LemonRequestParams params) {
        HandlerCallback<LedgerBuildingCheckItemDetailVo> callback = new HandlerCallback<LedgerBuildingCheckItemDetailVo>(KeyConstants.URL_GET_SAFE_LEDGER_BUILDING_CHECK_ITEM_DETAIL) {
        };
        String serverUrl = mSharedPreferencesServer.getRequestUrl(UrlInfo.GET_SAFE_LEDGER_BUILDING_CHECK_ITEM_DETAIL, Constants.SERVER_V2);
        OkHttpUtils.post()
                .url(serverUrl)
                .tag(callback.getTag())
                .params(params)
                .build().execute(callback);
    }


    /**
     * 首页概览信息
     *
     * @param params
     */
    public void getHomePageInfo(LemonRequestParams params) {
        HandlerCallback<OverViewVo> callback = new HandlerCallback<OverViewVo>(KeyConstants.URL_GET_HOME_PAGE_INFO) {
        };
        String serverUrl = mSharedPreferencesServer.getRequestUrl(UrlInfo.GET_HOME_PAGE_INFO, Constants.SERVER_V2);
        OkHttpUtils.post()
                .url(serverUrl)
                .tag(callback.getTag())
                .params(params)
                .build().execute(callback);
    }

}
